package com.zf.admin.conf;

import com.github.pagehelper.PageHelper;
import com.zf.admin.utils.jwt.MyFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @author LJH
 * @date 2019/7/16-6:16
 * @QQ 1755497577
 */
@Configuration
public class BeanRegisterConfig {

    @Bean
    public FilterRegistrationBean createFilterBean() {
        //过滤器注册类
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new MyFilter());
        registration.addUrlPatterns("/toindex");
        registration.addUrlPatterns("/paid/*");
        registration.addUrlPatterns("/wrong/*");
        registration.addUrlPatterns("/findapplylist");
        registration.addUrlPatterns("/applychangehousestatus");
        registration.addUrlPatterns("/refuseapply");
        registration.addUrlPatterns("/applyout/*");
        registration.addUrlPatterns("/zulist/*");
        registration.addUrlPatterns("/schedule/*");
        registration.addUrlPatterns("/ahouselist");
        registration.addUrlPatterns("/addhouse");
        registration.addUrlPatterns("/toaddhouse");
        registration.addUrlPatterns("/deletehouse");
        registration.addUrlPatterns("/toahouselist");
        registration.addUrlPatterns("/findid");
        registration.addUrlPatterns("/findhouseidupdate");
        registration.addUrlPatterns("/checkout/**");
        registration.addUrlPatterns("/findalluserlist");
        registration.addUrlPatterns("/deleteuserlist");
        registration.addUrlPatterns("/hetong/*");

        return registration;
    }

    //配置mybatis的分页插件pageHelper
    @Bean
    public PageHelper pageHelper() {
        PageHelper pageHelper = new PageHelper();
        Properties properties = new Properties();
        properties.setProperty("offsetAsPageNum", "true");
        properties.setProperty("pageSizeZero", "true");
        properties.setProperty("rowBoundsWithCount", "true");
        properties.setProperty("reasonable", "true");
        //配置mysql数据库
        properties.setProperty("dialect", "mysql");
        pageHelper.setProperties(properties);
        return pageHelper;
    }
}